package com.tedu.ourprojct.controller;

import com.tedu.ourprojct.mapper.FoodPackageLinkMapper;
import com.tedu.ourprojct.mapper.FoodPackageMapper;
import com.tedu.ourprojct.pojo.dto.FoodPackageDto;
import com.tedu.ourprojct.pojo.dto.FoodPackageLinkDto;
import com.tedu.ourprojct.pojo.dto.FoodPackageUpdateDto;
import com.tedu.ourprojct.pojo.entity.FoodPackage;
import com.tedu.ourprojct.pojo.entity.FoodPackageLink;
import com.tedu.ourprojct.pojo.vo.FoodPackageAdminVO;
import com.tedu.ourprojct.pojo.vo.FoodPackageLinkAdminVO;
import com.tedu.ourprojct.pojo.vo.FoodPackageUpdateVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * 套餐信息处理类
 * @author 袁田
 */
@Slf4j
@RestController
@RequestMapping("/foodPackageLink")
public class FoodPackageLinkController {
    @Autowired(required = false)
    FoodPackageLinkMapper mapper;



    @RequestMapping("/insert")
    public void insert(@RequestBody FoodPackageLinkDto foodPackageLinkDto){
        log.info("传来的餐品套餐关联"+foodPackageLinkDto);
        FoodPackageLink foodPackageLink=new FoodPackageLink();
        BeanUtils.copyProperties(foodPackageLinkDto,foodPackageLink);
        foodPackageLink.setCreated(new Date());
        mapper.insert(foodPackageLink);
    }

    @RequestMapping("/select")
    public List<FoodPackageLinkAdminVO> select(){
        return mapper.select();
    }







}
